package org.springframework.boot.netty.codec;

import com.google.protobuf.Message;
import com.google.protobuf.MessageLite;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Author: huoxingzhi
 * Date: 2021/1/7
 * Email: hxz_798561819@163.com
 */
public class ProtoBufCodecBean {

    private Message message;

    private Map<String,String> headers = new HashMap<>();

    public ProtoBufCodecBean() {
    }

    public ProtoBufCodecBean(Map<String, String> headers,Message message) {
        this.headers = headers;
        this.message = message;
    }

    public Message getMessage() {
        return message;
    }

    public void setMessage(Message message) {
        this.message = message;
    }

    public String getHeader() {
        StringBuilder builder = new StringBuilder();
        headers.entrySet().forEach(stringStringEntry -> {
            builder.append(stringStringEntry.getValue()).append("=").append(stringStringEntry.getValue()).append("&");
        });

        return StringUtils.substringAfterLast(builder.toString(),"&");
    }

    public Map<String, String> getHeaders() {
        return this.headers;
    }

    public void setHeaders(Map<String, String> headers) {
        this.headers = headers;
    }
}
